import request from '@/utils/request'


//格式化时间
export function formatDate(date){
  var year = date.getFullYear();
  var month = date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1;
  var day = date.getDate() < 10 ? '0' + date.getDate() : date.getDate();
  var hours = date.getHours() < 10 ? '0' + date.getHours() : date.getHours();
  var minutes = date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes();
  var seconds = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds();
  return year + '-' + month + '-' + day + ' ' + hours + ':' + minutes + ':' + seconds;
}

//确认支付订单
export function checkoutOrder(ids){
  console.log("确认支付订单",ids)
  return request({
    url: '/system/orderlist/checkoutOrder/'+ids,
    method: 'post',
  })
}

//提交评价
export function evaluate(data) {
  return request({
    url: '/system/orderlist/evaluate',
    method: 'post',
    data: data
  })
}

//确认收货
export function receiveOrder(data){
  return request({
    url: '/system/orderlist/receiveOrder',
    method: 'post',
    data: data
  })
}

//修改订单商品
export function updateOrderGoods(data){
  return request({
    url: '/system/orderlist/updateOrderGoods',
    method: 'post',
    data: data
  })
}

// 查询采购单商品列表
export function getOrderGoodsDetail(id) {
  return request({
    url: '/system/orderlist/getListGoods',
    method: 'get',
    params:{"id":id}
  })
}

// 查询采购单列表
export function listOrderlist(query) {
  console.log("查询采购单",query)
  return request({
    url: '/system/orderlist/list',
    method: 'get',
    params: query
  })
}

// 查询采购单详细
export function getOrderlist(id) {
  return request({
    url: '/system/orderlist/' + id,
    method: 'get'
  })
}

// 新增采购单
export function addOrderlist(data) {
  return request({
    url: '/system/orderlist',
    method: 'post',
    data: data
  })
}

// 修改采购单
export function updateOrderlist(data) {
  return request({
    url: '/system/orderlist',
    method: 'put',
    data: data
  })
}

// 删除采购单
export function delOrderlist(id) {
  return request({
    url: '/system/orderlist/' + id,
    method: 'delete'
  })
}
